<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>标签编辑</title>
    <meta name="description" content="">
    <meta name="keywords" content="">
    <link href="" rel="stylesheet">
    <script type="text/javascript" src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/bower_components/jquery/dist/jquery.min.js"></script>
    <script type="text/javascript" src="/dist/js/adminlte.min.js"></script>


    <link rel="stylesheet" type="text/css" href="/dist/css/AdminLTE.min.css">
    <link rel="stylesheet" type="text/css" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/bower_components/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="/bower_components/Ionicons/css/ionicons.min.css">
    <link rel="stylesheet" type="text/css" href="/dist/css/skins/skin-blue.min.css">
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

    <!-- Main Header -->
    <!-- Main Header -->
    <header th:include="admin_public :: header" class="main-header">
    </header>


    <!-- Left side column. contains the logo and sidebar -->
    <aside th:include="admin_public :: sidebar" class="main-sidebar">
    </aside>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->


        <!-- Main content -->
        <section class="content container-fluid">

            <hr/>
            <div>
                <!-- Horizontal Form -->
                <div class="box box-info">
                    <div class="box-header with-border">
                        <h3 class="box-title">标签管理-编辑</h3>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start --><div class="form-horizontal">
                    <div class="box-body">
                        <div style="display: none" id="LabelId"  th:text="${label.id}">
                        </div>
                            <div class="form-group">
                                <label for="LabelName" class="col-sm-2 control-label">标签名</label>

                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="LabelName"
                                           th:value="${label.labelName}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="LabelNumber" class="col-sm-2 control-label">序号</label>

                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="LabelNumber"  th:value="${label.labelNumber}">
                                </div>
                            </div>

                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">

                            <!--<button type="submit" class="btn btn-success btn-flat" onclick="deleteLabel()">删除</button>-->

                            <button type="submit" class="btn btn-success btn-flat" onclick="updateLabel()">更改</button>
                        </div>
                        <!-- /.box-footer -->
                    </div>
                </div>
                <!-- /.box -->
            </div>


        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->

    <!-- Main Footer -->
    <footer th:include="admin_public :: footer" class="main-footer">
    </footer>

    <!-- Control Sidebar -->
    <aside th:include="admin_public :: control" class="control-sidebar control-sidebar-dark">
    </aside>

    <div class="control-sidebar-bg"></div>
    
    <script>
        function updateLabel() {
            var label = {
                id : $("#LabelId").html(),
                labelName : $("#LabelName").val(),
                labelNumber : $("#LabelNumber").val(),
            };
            $.ajax({
                type: 'post',
                url: "/admin/label/updateLabel",
                //headers: {'Content-type': 'application/json;charset=UTF-8'},
                contentType : 'application/json;charset=UTF-8',
                dataType: "json",
                data : JSON.stringify(label),
                success : function(result) {
                    alert("更改成功");
                    window.location.href="/admin/label/editLabels"
                },
                error : function(result){
                    alert("失败了");
                }
            })
        }



        // function deleteLabel() {
        //     var id=$("#LabelId").html()
        //     $.ajax({
        //         type: 'post',
        //         url: "/api/v1/label/deleteLabel?id="+id,
        //         //headers: {'Content-type': 'application/json;charset=UTF-8'},
        //         contentType : 'application/json;charset=UTF-8',
        //         //data :{id:$("#LabelId").html()},
        //         success : function(result) {
        //             alert("删除成功");
        //             window.location.href="/api/v1/label/editLabels"
        //         },
        //         error : function(result){
        //             alert("失败了");
        //         }
        //     })
        // }
        
    </script>
</div>
</body>
</html>